#include <iostream>
using std::cout;
using std::endl;

int add(int x,int y = 1){
    cout << "add(int,int)" << endl;
    return x + y;
}

double add(double x,double y){
    cout << "add(double,double)" << endl;
    return x + y;
}


int add(int x,int y,int z = 0){
    cout << "add(int,int,int)" << endl;
    return x + y + z;
}

//包裹的内容会按照C编译器的方式进行编译
/* extern "C" */
/* { */

float add(int x, float y){
    cout << "add(int,float)" << endl;
    return x + y;
}

float add(float x, int y){
    cout << "add(float,int)" << endl;
    return x + y;
}

/* } */

//只有返回类型不同，不能构成重载
/* void add(float x, int y){ */
/*     cout << x + y << endl; */
/* } */

void test0(){
    int a = 10, b = 20, e = 70;
    double c = 2.8, d = 4.5;
    float f = 1.7, g = 7.6;
    /* cout << add(a,b) << endl; */
    cout << add(c,d) << endl;
    cout << add(a,b,e) << endl;
    cout << add(a,f) << endl;
    cout << add(g,b) << endl;
}

void test1(){
    int a = 10, b = 20, c = 70;
    cout << add(a) << endl;
    /* cout << add(a,b) << endl; */
    cout << add(a,b,c) << endl;


}

int main(void){
    test1();
    return 0;
}
